package com.nanfang51g3.ckz.ui.money.preview;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.nanfang51g3.ckz.R;
import com.nanfang51g3.ckz.application.CkzApplication;
import com.nanfang51g3.ckz.ui.base.IPresenter;
import com.nanfang51g3.ckz.ui.base.Base2Activity;
import com.nanfang51g3.ckz.ui.money.add.AddFinancialInfoActivity;
import com.nanfang51g3.ckz.utils.AppManager;
import com.nanfang51g3.ckz.utils.EasyToast;
import com.nanfang51g3.ckz.utils.KLog;
import com.nanfang51g3.ckz.utils.SPUtil;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by Administrator on 2016/4/19.
 */
public class PreviewMoneyInfoActivity extends Base2Activity implements PreviewMoneyInfoContract.View {
    PreviewMoneyInfoContract.PreviewMoneyInfoActionsListener previewMoneyInfoActionsListener;
    @Bind(R.id.preview_money_info_name)
    TextView previewMoneyInfoName;
    @Bind(R.id.preview_money_info_bank)
    TextView previewMoneyInfoBank;
    @Bind(R.id.preview_money_info_card)
    TextView previewMoneyInfoCard;
    @Bind(R.id.preview_money_info_ali_pay)
    TextView previewMoneyInfoAliPay;
    @Override
    public IPresenter getPresenter() {
        return null;
    }

    @Override
    public int getContentView() {
        return R.layout.preview_money_info;
    }

    @Override
    public boolean isShowLeftIcon() {
        return true;
    }

    @Override
    public boolean isShowRightIcon() {
        return false;
    }

    @Override
    public int setLeftIcon() {
        return R.mipmap.ic_accounting_left;
    }

    @Override
    public int setRightIcon() {
        return 0;
    }

    @Override
    public int showTitle() {
        return R.string.str_preview_info;
    }

    @Override
    public void onClickLeft(View v) {
        AppManager.getAppManager().finishActivity(this);
    }

    @Override
    public void onClickRight(View v) {
        EasyToast.showShort(this, "msg");
    }


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        previewMoneyInfoActionsListener = DaggerPreviewMoneyInfoContractComponent
                .builder()
                .appComponent(CkzApplication.getAppComponent())
                .previewMoneyInfoPresenterModule(new PreviewMoneyInfoPresenterModule(this))
                .build().getPreviewMoneyInfoPresenter();
        KLog.i("TAG", previewMoneyInfoActionsListener == null ? "previewMoneyInfoActionsListener==null" : "previewMoneyInfoActionsListener!=null");
        ButterKnife.bind(this);
    }

    @Override
    protected void onResume() {
        super.onResume();
        String real_name = (String) SPUtil.get(this, "real_name", "暂未填写");
        String bank_name = (String) SPUtil.get(this, "bank_name", "暂未填写");
        String bank_card = (String) SPUtil.get(this, "bank_card", "暂未填写");
        String ali_pay_card = (String) SPUtil.get(this, "ali_pay_card", "暂未填写");
        previewMoneyInfoName.setText(real_name);
        previewMoneyInfoBank.setText(bank_name);
        previewMoneyInfoCard.setText(bank_card);
        previewMoneyInfoAliPay.setText(ali_pay_card);

    }

    @OnClick(R.id.relative_preview_name)
    public void relative_preview_name(View view) {
        startActivity(new Intent(PreviewMoneyInfoActivity.this, AddFinancialInfoActivity.class).putExtra("id_title", R.string.str_financial_name).putExtra("id_type", 2));
    }

    @OnClick(R.id.relative_preview_bank)
    public void relative_preview_bank(View view) {
        startActivity(new Intent(PreviewMoneyInfoActivity.this, AddFinancialInfoActivity.class).putExtra("id_title", R.string.str_financial_bank).putExtra("id_type", 2));
    }

    @OnClick(R.id.relative_preview_card)
    public void relative_preview_card(View view) {
        startActivity(new Intent(PreviewMoneyInfoActivity.this, AddFinancialInfoActivity.class).putExtra("id_title", R.string.str_financial_card).putExtra("id_type", 2));
    }

    @OnClick(R.id.relative_preview_ali_pay)
    public void relative_preview_ali_pay(View view) {
        startActivity(new Intent(PreviewMoneyInfoActivity.this, AddFinancialInfoActivity.class).putExtra("id_title", R.string.str_financial_ali_pay).putExtra("id_type", 1));
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ButterKnife.unbind(this);//解除绑定，官方文档只对fragment做了解绑
    }

}
